package util;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * User: key
 * ClassName:StrUtils
 * Date: 2023/5/6
 * Time: 14:32
 * description:
 */
public class StrUtils {
    private static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
    public static boolean isNotEmpty(String data){
        return data != null && !data.trim().equals("");
    }
    public static Integer strToInteger(String data){
        if(isNotEmpty(data)){
            return Integer.valueOf(data);
        }
        return -1;
    }
    public static Double strToDouble(String data){
        if(isNotEmpty(data)){
            return Double.valueOf(data);
        }
        return -1.0;
    }
    public static Date strToDate(String data){
        try {
            return sdf.parse(data);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return null;
    }
}
